home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
libs
/
intuisup.lha
/
Intuisup
/
source.lha
/
Editor
/
screen.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-10-05
|
11KB
|
379 lines
/* $Revision Header *** Header built automatically - do not edit! ***********
*
* (C) Copyright 1992 by Torsten Jürgeleit
*
* Name .....: screen.c
* Created ..: Friday 02-Oct-92 10:31:18
* Revision .: 1
*
* Date Author Comment
* ========= ==================== ====================
* 02-Oct-92 Michael Bjerking New realese, better Screen/Window editor
* 02-Oct-92 Michael Bjerking Created this file!
*
* $Revision Header ********************************************************/
/* Includes */
#include "includes.h"
#include "defines.h"
#include "imports.h"
#include "protos.h"
/* Screen data */
struct NewScreen editor_new_screen =
{
0, /* LetfEdge (not used) */
0, /* TopEdge */
320, /* Width (320=Low, 640=High resolution) */
200, /* Height (200=non -> 400=interlace) */
2, /* Depth (1-6 => 2-64 colours) */
0, /* DetailPen */
1, /* BlockPen */
0, /* ViewModes - flags: HIRES, INTERLACE,
SPRITES, DUALPF, HAM */
CUSTOMSCREEN, /* Type (CUSTOMSCREEN or CUSTOMBITMAP) */
NULL, /* Font (NULL or struct Textattr) */
(UBYTE *) & editor_screen_title[0], /* DefaultTitle (NULL or NULL terminating string)*/
NULL, /* Gadgets (pointer to first gadget) */
NULL /* CustomBitap (pointer to BitMap) */
};
USHORT editor_screen_type = EDITOR_SCREEN_TYPE_WBENCH;
/* Data for fonts */
STATIC struct TextAttr screen_text_attr[]=
{
{
(STRPTR) "topaz.font", 8, FS_NORMAL, FPF_ROMFONT
}
};
/* Defines and data for gadgets */
#define SCREEN_GADGET_LEFTEDGE 0
#define SCREEN_GADGET_TOPEDGE 1
#define SCREEN_GADGET_WIDTH 2
#define SCREEN_GADGET_HEIGHT 3
#define SCREEN_GADGET_DEPTH 4
#define SCREEN_GADGET_DETAILPEN 5
#define SCREEN_GADGET_BLOCKPEN 6
#define SCREEN_GADGET_INTERLACE 7
#define SCREEN_GADGET_SPRITES 8
#define SCREEN_GADGET_DUALPF 9
#define SCREEN_GADGET_HIRES 10
#define SCREEN_GADGET_HAM 11
#define SCREEN_GADGET_TITLE 12
#define SCREEN_GADGET_SCREENTYPE 13
#define SCREEN_GADGET_OK 14
#define SCREEN_GADGET_CANCEL 15
STATIC BYTE *screen_gadget14_text_array[]=
{
"WBENCHSCREEN",
"CUSTOMSCREEN",
"CUSTOMBITMAP",
NULL
};
STATIC struct GadgetData screen_gadget_data[]=
{
{
5, 65, 296, 4, 71, 14,
"LeftEdge ", &screen_text_attr[0],
{10, 0, (VOID *) 0}
},
{
5, 64, 296, 19, 71, 14,
"TopEdge ", &screen_text_attr[0],
{10, 0, (VOID *) 0}
},
{
5, 64, 296, 34, 71, 14,
"Width ", &screen_text_attr[0],
{10, 0, (VOID *) 320}
},
{
5, 64, 296, 49, 71, 14,
"Height ", &screen_text_attr[0],
{10, 0, (VOID *) 200}
},
{
9, 64, 446, 80, 51, 12,
"Depth", &screen_text_attr[0],
{1, 6, (VOID *) 2}
},
{
5, 64, 296, 64, 71, 14,
"DetailPen", &screen_text_attr[0],
{10, 0, (VOID *) 0}
},
{
5, 64, 296, 79, 71, 14,
"BlockPen ", &screen_text_attr[0],
{10, 0, (VOID *) 1}
},
{
2, 64, 476, 19, 21, 11,
"INTERLACE", &screen_text_attr[0],
{0, 1, (VOID *) 0}
},
{
2, 64, 476, 34, 21, 11,
"SPRITES ", &screen_text_attr[0],
{0, 1, (VOID *) 0}
},
{
2, 64, 476, 49, 21, 11,
"DUALPF ", &screen_text_attr[0],
{0, 1, (VOID *) 0}
},
{
2, 64, 476, 4, 21, 11,
"HIRES ", &screen_text_attr[0],
{0, 1, (VOID *) 0}
},
{
2, 64, 476, 64, 21, 11,
"HAM ", &screen_text_attr[0],
{0, 1, (VOID *) 0}
},
{
4, 256, 36, 75, 110, 14,
"DefaultTitle", &screen_text_attr[0],
{20, 0, "Screen"}
},
{
3, 64, 21, 19, 138, 37,
"Screen Type:", &screen_text_attr[0],
{1, 0, &screen_gadget14_text_array[0]}
},
{
1, 16, 50, 95, 110, 15,
"_Ok", &screen_text_attr[0],
{0, 0, (VOID *) 0}
},
{
1, 16, 340, 95, 110, 15,
"_Cancel", &screen_text_attr[0],
{0, 0, (VOID *) 0}
},
{
INTUISUP_DATA_END
}
};
SHORT
change_project_screen(VOID)
{
struct GadgetData *gd = &screen_gadget_data[0];
APTR gl;
SHORT status;
/* Init gadgets with current values */
(gd + SCREEN_GADGET_LEFTEDGE)->gd_SpecialData.gd_InputData.gd_InputDefault = (VOID *) editor_new_screen.LeftEdge;
(gd + SCREEN_GADGET_TOPEDGE)->gd_SpecialData.gd_InputData.gd_InputDefault = (VOID *) editor_new_screen.TopEdge;
(gd + SCREEN_GADGET_WIDTH)->gd_SpecialData.gd_InputData.gd_InputDefault = (VOID *) editor_new_screen.Width;
(gd + SCREEN_GADGET_HEIGHT)->gd_SpecialData.gd_InputData.gd_InputDefault = (VOID *) editor_new_screen.Height;
(gd + SCREEN_GADGET_DETAILPEN)->gd_SpecialData.gd_InputData.gd_InputDefault = (VOID *) editor_new_screen.DetailPen;
(gd + SCREEN_GADGET_BLOCKPEN)->gd_SpecialData.gd_InputData.gd_InputDefault = (VOID *) editor_new_screen.BlockPen;
(gd + SCREEN_GADGET_TITLE)->gd_SpecialData.gd_InputData.gd_InputDefault = (BYTE *) editor_new_screen.DefaultTitle;
(gd + SCREEN_GADGET_HIRES)->gd_SpecialData.gd_CheckData.gd_CheckSelected = (ULONG) (editor_new_screen.ViewModes & HIRES ? 1 : 0);
(gd + SCREEN_GADGET_INTERLACE)->gd_SpecialData.gd_CheckData.gd_CheckSelected = (ULONG) (editor_new_screen.ViewModes & INTERLACE ? 1 : 0);
(gd + SCREEN_GADGET_SPRITES)->gd_SpecialData.gd_CheckData.gd_CheckSelected = (ULONG) (editor_new_screen.ViewModes & SPRITES ? 1 : 0);
(gd + SCREEN_GADGET_DUALPF)->gd_SpecialData.gd_CheckData.gd_CheckSelected = (ULONG) (editor_new_screen.ViewModes & DUALPF ? 1 : 0);
(gd + SCREEN_GADGET_HAM)->gd_SpecialData.gd_CheckData.gd_CheckSelected = (ULONG) (editor_new_screen.ViewModes & HAM ? 1 : 0);
(gd + SCREEN_GADGET_SCREENTYPE)->gd_SpecialData.gd_MXData.gd_MXActiveEntry = (ULONG) editor_screen_type;
/* Print title and display gadgets */
IClearWindow(eri, ewin, 0, 0, EDITOR_WINDOW_WIDTH, EDITOR_WINDOW_HEIGHT, 0);
if (!(gl = ICreateGadgets(eri, &screen_gadget_data[0], 0, 0, NULL)))
status = EDITOR_ERROR_OUT_OF_MEM;
else
{
/* Init IDCMPFlag and Flag list */
IDisplayGadgets(ewin, gl);
status = change_project_screen_action(gl);
IRemoveGadgets(gl);
IFreeGadgets(gl);
}
return (status);
}
STATIC SHORT
change_project_screen_action(APTR gl)
{
struct MsgPort *up = ewin->UserPort;
BOOL keepon = TRUE;
do
{
struct IntuiMessage *msg;
WaitPort(up);
while (msg = IGetMsg(up))
{
ULONG Class = msg->Class;
USHORT Code = msg->Code;
LONG IAddress = (LONG) msg->IAddress;
switch (Class)
{
case CLOSEWINDOW:
keepon = FALSE;
break;
case ISUP_ID:
switch (Code)
{
case SCREEN_GADGET_LEFTEDGE:
printf("SCREEN_GADGET_LEFTEDGE: %ld\n", IAddress);
break;
case SCREEN_GADGET_TOPEDGE:
printf("SCREEN_GADGET_TOPEDGE: %ld\n", IAddress);
editor_new_screen.TopEdge = (SHORT) IAddress;
break;
case SCREEN_GADGET_WIDTH:
printf("SCREEN_GADGET_WIDTH: %ld\n", IAddress);
editor_new_screen.Width = (SHORT) IAddress;
break;
case SCREEN_GADGET_HEIGHT:
printf("SCREEN_GADGET_HEIGHT: %ld\n", IAddress);
editor_new_screen.Height = (SHORT) IAddress;
break;
case SCREEN_GADGET_DEPTH:
printf("SCREEN_GADGET_DEPTH: %ld\n", IAddress);
editor_new_screen.Depth = (SHORT) IAddress;
break;
case SCREEN_GADGET_DETAILPEN:
printf("SCREEN_GADGET_DETAILPEN: %ld\n", IAddress);
editor_new_screen.DetailPen = (UBYTE) IAddress;
break;
case SCREEN_GADGET_BLOCKPEN:
printf("SCREEN_GADGET_BLOCKPEN: %ld\n", IAddress);
editor_new_screen.BlockPen = (UBYTE) IAddress;
break;
case SCREEN_GADGET_INTERLACE:
printf("SCREEN_GADGET_INTERLACE: %ld\n", IAddress);
if (IAddress)
editor_new_screen.ViewModes = (USHORT) editor_new_screen.ViewModes | INTERLACE;
else
editor_new_screen.ViewModes = (USHORT) editor_new_screen.ViewModes ^ INTERLACE;
break;
case SCREEN_GADGET_SPRITES:
printf("SCREEN_GADGET_SPRITES: %ld\n", IAddress);
if (IAddress)
editor_new_screen.ViewModes = (USHORT) editor_new_screen.ViewModes | SPRITES;
else
editor_new_screen.ViewModes = (USHORT) editor_new_screen.ViewModes ^ SPRITES;
break;
case SCREEN_GADGET_DUALPF:
printf("SCREEN_GADGET_DUALPF: %ld\n", IAddress);
if (IAddress)
{
if ((editor_new_screen.ViewModes & HIRES) || (editor_new_screen.ViewModes & HAM))
{
printf("Hires, Ham and Dualpf not allowed at the same time\n");
ISetGadgetAttributes(gl, SCREEN_GADGET_DUALPF, 0L, 0L, 0L, 0L, (VOID *) 0);
}
else
editor_new_screen.ViewModes = (USHORT) editor_new_screen.ViewModes | DUALPF;
}
else
editor_new_screen.ViewModes = (USHORT) editor_new_screen.ViewModes ^ DUALPF;
break;
case SCREEN_GADGET_HIRES:
printf("SCREEN_GADGET_HIRES: %ld\n", IAddress);
if (IAddress)
{
if ((editor_new_screen.ViewModes & DUALPF) || (editor_new_screen.ViewModes & HAM))
{
printf("Hires, Ham and Dualpf not allowed at the same time\n");
ISetGadgetAttributes(gl, SCREEN_GADGET_HIRES, 0L, 0L, 0L, 0L, (VOID *) 0);
}
else
editor_new_screen.ViewModes = (USHORT) editor_new_screen.ViewModes | HIRES;
}
else
editor_new_screen.ViewModes = (USHORT) editor_new_screen.ViewModes ^ HIRES;
break;
case SCREEN_GADGET_HAM:
printf("SCREEN_GADGET_HAM: %ld\n", IAddress);
if (IAddress)
{
if ((editor_new_screen.ViewModes & HIRES) || (editor_new_screen.ViewModes & DUALPF))
{
printf("Hires, Ham and Dualpf not allowed at the same time\n");
ISetGadgetAttributes(gl, SCREEN_GADGET_HAM, 0L, 0L, 0L, 0L, (VOID *) 0);
}
else
editor_new_screen.ViewModes = (USHORT) editor_new_screen.ViewModes | HAM;
}
else
editor_new_screen.ViewModes = (USHORT) editor_new_screen.ViewModes ^ HAM;
break;
case SCREEN_GADGET_TITLE:
printf("SCREEN_GADGET_TITLE: %s\n", IAddress);
sprintf((BYTE *) editor_new_screen.DefaultTitle, "%s", IAddress);
break;
case SCREEN_GADGET_SCREENTYPE:
printf("SCREEN_GADGET_SCREENTYPE: %ld\n", IAddress);
switch ((USHORT) IAddress)
{
case EDITOR_SCREEN_TYPE_WBENCH:
editor_screen_type = EDITOR_SCREEN_TYPE_WBENCH;
break;
case EDITOR_SCREEN_TYPE_CUSTOM:
editor_screen_type = EDITOR_SCREEN_TYPE_CUSTOM;
break;
case EDITOR_SCREEN_TYPE_BITMAP:
editor_screen_type = EDITOR_SCREEN_TYPE_BITMAP;
break;
}
break;
case SCREEN_GADGET_OK:
/*
if( (screen=(struct Screen*)OpenScreen(&editor_new_screen))==NULL)
printf("Couldn't open screen\n");
else
{
Delay(200);
CloseScreen(screen);
}
*/
keepon = FALSE;
break;
case SCREEN_GADGET_CANCEL:
keepon = FALSE;
break;
}
}
IReplyMsg(msg);
}
}
while (keepon == TRUE);
return EDITOR_STATUS_NORMAL;
}